package net.xo68.destiny.manager.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import net.xo68.destiny.core.json.JsonMapper;
import net.xo68.destiny.manager.entity.Trigger;
import net.xo68.destiny.manager.mapper.TriggerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;



/** 
 * Trigger Service
 * @author wuxie(16349023@qq.com)
 * @date 2020年12月21日 21:43:52
 *
 */
@Slf4j
@Service
public class TriggerService {
    
    @Autowired
    private TriggerMapper triggerMapper;
    @Autowired
    private JsonMapper jsonMapper;

    public Trigger find(Long jobId) {
        return  triggerMapper.find(jobId);
    }

    public Trigger insert(Trigger trigger) {
        triggerMapper.insert(trigger);
        return trigger;
    }

    public Trigger update(Trigger trigger) {
        triggerMapper.update(trigger);
        return trigger;
    }
    
    public int delete(Long jobId) {
        return triggerMapper.delete(jobId);
    }
    
    public List<Trigger> list() {
        return triggerMapper.list();
    }
	
	public PageInfo<Trigger> list(int pageNumber,int pageSize) {
        PageHelper.startPage(pageNumber, pageSize,true);
        List<Trigger> docs = triggerMapper.list();
        PageInfo<Trigger> pageInfo = new PageInfo<Trigger>(docs);
        return pageInfo;
    }

}